﻿// Models/ExamResult.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace WebApplication1.Models
{
    /// <summary>
    /// 考试结果实体类
    /// </summary>
    [Table("ExamResults")]
    public class ExamResult
    {
        /// <summary>
        /// 结果ID
        /// </summary>
        [Key]
        public int ResultId { get; set; }

        /// <summary>
        /// 用户ID
        /// </summary>
        [Required]
        public int UserId { get; set; }

        /// <summary>
        /// 考试ID
        /// </summary>
        [Required]
        public int ExamId { get; set; }

        /// <summary>
        /// 考试开始时间
        /// </summary>
        [Display(Name = "开始时间")]
        [Column(TypeName = "datetime2")] // 指定使用 datetime2 类型
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 考试结束时间
        /// </summary>
        [Display(Name = "结束时间")]
        [Column(TypeName = "datetime2")] // 指定使用 datetime2 类型
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 总分
        /// </summary>
        [Display(Name = "总分")]
        public int TotalScore { get; set; }

        /// <summary>
        /// 得分
        /// </summary>
        [Display(Name = "得分")]
        public int Score { get; set; }

        /// <summary>
        /// 用户
        /// </summary>
        public virtual User User { get; set; }

        /// <summary>
        /// 考试
        /// </summary>
        public virtual Exam Exam { get; set; }

        /// <summary>
        /// 用户答案集合
        /// </summary>
        public virtual ICollection<UserAnswer> UserAnswers { get; set; }
    }
}